{{ define "title" }}
{{ .Title }} | {{ site.Title }}
{{ end }}

{{ define "main" }}
{{ $desc := .Description }}
{{ $numSections := len .Sections }}
{{ $isRoot := eq .FirstSection .CurrentSection }}
<div class="relative max-w-3xl md:max-w-5xl lg:max-w-7xl mx-auto px-6 lg:px-8 my-16">
  <div>
    {{ partial "hero.html" . }}
  </div>

  <div class="mt-8">
    {{ if $isRoot }}
    {{ $columnedSections := where .Sections ".Params.self_standing" "ne" true }}
    {{ $fullWidthSections := where .Sections ".Params.self_standing" true  }}

    <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
      {{ range $columnedSections }}
      <div>
        <span class="prose dark:prose-dark">
          {{ partial "heading.html" (dict "text" .Title "level" 2 "href" .RelPermalink "icon" false) }}
        </span>

        {{ with .Description }}
        <div class="mt-4 text-lg leading-tight prose dark:prose-dark">
          {{ . | markdownify }}
        </div>
        {{ end }}

        <div class="mt-4">
          {{ .Render "list" }}
        </div>
      </div>
      {{ end }}
    </div>

    {{ range $fullWidthSections }}
    <div class="mt-12">
      <span class="prose dark:prose-dark">
        {{ partial "heading.html" (dict "text" .Title "level" 2 "href" .RelPermalink "icon" false) }}
      </span>

      {{ with .Description }}
        <div class="mt-4 text-lg leading-tight prose dark:prose-dark">
          {{ . | markdownify }}
        </div>
        {{ end }}

      <div class="mt-4 grid grid-cols-1 md:grid-cols-2">
        {{ range .Sections }}
        <div>
          <span class="prose dark:prose-dark">
            {{ partial "heading.html" (dict "text" .Title "level" 3 "href" .RelPermalink "icon" false) }}
          </span>

          {{ with .Description }}
          <div class="mt-2 prose-xl dark:prose-dark leading-snug">
            {{ . | markdownify }}
          </div>
          {{ end }}

          <div class="mt-3">
            {{ .Render "list" }}
          </div>
        </div>
        {{ end }}
      </div>
    </div>
    {{ end }}
    {{ else }}
    <div class="mt-4">
      {{ with .Sections }}
      <div class="grid grid-cols-2">
        {{ range . }}
        <div>
          <span class="prose dark:prose-dark">
            {{ partial "heading.html" (dict "text" .Title "level" 3 "href" .RelPermalink "icon" false) }}
          </span>

          {{ with .Description }}
          <div class="mt-2 prose-xl dark:prose-dark leading-snug">
            {{ . | markdownify }}
          </div>
          {{ end }}

          <div class="mt-3">
            {{ .Render "list" }}
          </div>
        </div>
        {{ end }}
      </div>
      {{ else }}
      {{ .Render "list" }}
      {{ end }}
    </div>
    {{ end }}
  </div>
</div>
{{ end }}

{{ define "below" }}
{{ partial "guides/pagination.html" . }}
{{ end }}